#include "startwindow.h"
#include "labelbutton.h"
#include "../logic/user.h"

#include <QVBoxLayout>
#include <QPixmap>
#include <QtDebug>

StartWindow::StartWindow( QWidget * parent ) : WhaleWindow( parent ) {
    // set socialwhale logo
    QLabel * logo = new QLabel();
    logo->setPixmap( QPixmap( ":/images/socialwhale-big.png" ) );
    logo->setObjectName( "loginlogo" );
    logo->setAlignment( Qt::AlignCenter );
        
    // set welcome message
    QLabel * welcome = new QLabel( "Welcome to Social Whale! Please login with twitter:" );
    welcome->setAlignment( Qt::AlignCenter );

    // set authentication button
    LabelButton * authButton = new LabelButton();
    authButton->setPixmap( QPixmap( ":/images/buttons/twitteroauth.jpg" ) );
    authButton->setAlignment( Qt::AlignCenter );

    // layout holding all items
    QVBoxLayout * masterLayout = new QVBoxLayout();
    masterLayout->addSpacing( 50 );
    masterLayout->addWidget( logo );
    masterLayout->addSpacing( 50 );
    masterLayout->addWidget( welcome );
    masterLayout->addWidget( authButton );
    masterLayout->setAlignment( Qt::AlignTop );
    masterLayout->setSpacing( 10 );

    // create a central widget to hold layout
    QWidget * central = new QWidget();
    central->setLayout( masterLayout );

    // inform parent class
    this->setCentralWidget( central );

    // connect authentication button 
    connect( authButton, SIGNAL( clicked() ), User::instance(), SLOT( startLogin() ) );

    // set title
    this->setWindowTitle( "Social Whale" );
}
